/******************************************************************************
 * Copyright (C) 2024 EternalChip, Inc.(Gmbh) or its affiliates.
 * 
 * All Rights Reserved.
 * 
 * File name: ec_bsp_aht21_driver.h
 * 
 * Description: Provide the HAL APIs of AHT21 and corresponding opetions.
 * 
 * Processing flow:
 * 
 * call directly.
 * 
 * 
 * Version: V1.0
 * 
 * Modifications:
 * 
 * Date: 2024-07-09 13:05:10
 * 
 * Author: su
 * 
 * Note: 1 tab == 4 spaces!
 * 
 *****************************************************************************/


//******************************** Includes *********************************//

#ifndef __EC_BSP_AHT21_DRIVER_H__  //Avoid repeated including same files later
#define __EC_BSP_AHT21_DRIVER_H__

#include "ec_bsp_aht21_reg.h"      // aht21寄存器.h文件         
//******************************** Includes *********************************//
#include <stdio.h>             	   
#include <stdint.h>
//******************************** Defines **********************************//

//定义IIC接口
typedef struct
{
	int8_t (*pfinit     )                                       (void);
	int8_t (*pfdeinit   )                                       (void);
	int8_t (*pfwrite_reg) (uint8_t addr, uint8_t *pdata, uint8_t size);
	int8_t (*pfread_reg ) (uint8_t addr, uint8_t *pdata, uint8_t size);
} iic_driver_interface_t;

//定义时基
typedef struct 
{
	void (*delay_us)(uint32_t us);
	void (*delay_ms)(uint32_t ms);
}system_timebase_interface_t;

typedef struct bsp_aht21{
	iic_driver_interface_t         *piicdriver_interface; 		  // IIC接口
	system_timebase_interface_t     *ptimebase_interface;         // 时基接口	
	int8_t (*pfinit)(struct bsp_aht21 *aht21_instance);           // #1 初始化函数
	int8_t (*pfdeinit)(void);                                     // #2 去初始化函数
	int8_t (*pfread_id)(void);                                    // #3 读取ID函数
	int8_t (*pfread_temphumidata)(float *temp,float *humi);       // #4 读取温湿度
	int8_t (*pfread_temperature)(float *temp);					  // #5 读温度
	int8_t (*pfread_humidity)(float *humi);						  // #6 读湿度
	int8_t (*pfhibernating)(void);								  // #7 休眠
	int8_t (*pfwakeup)(void);                                     // #8 唤醒
}bsp_aht21_t;
//******************************** Defines **********************************//

//******************************** Declaring ********************************//
int8_t aht21_inst(                                                // #1 初始化函数
				bsp_aht21_t * 			      aht21_instance,     // AHT21的实体实例
				iic_driver_interface_t *      iic_instance,       // IIC的实体实例   
				system_timebase_interface_t * timebase);            // 时基  
	   

//******************************** Defines **********************************//

#endif //__EC_BSP_AHT21_HAL_H__
